passwordbreachchecker

password breach checker

Description:

  • This program checks whether your password leaked in any Data Breaches.
  • Your can even do it at (https://haveibeenpwned.com/Passwords)
  • but Your password travels over internet right? so, its not safest method.
  • This works in most efficient way in your offline pc.
  • When You enter a password, it will be hashed with sha1
  • first 5 letters of hash code will be sent to haveibeenpwned API and receives a Dict of password Data with those first 5 characters of hashed password then this program crosscheck with the received hash and
  • finds whether your password leaked, if so how many times . else, it shows good to go. ## Instructions:
  1. Download passwordbreach.py
  2. Open Terminal/CMD/Powershell
  3. Go to Directory of passwordbreach.py (downloads folder in general)
  4. Execute the below cmd
  5. python3 passwordbreach.py x y z ( x,y,z are your passwords. You can enter infinite)

    Just ping me your doubts or to get collaborated on further projects!

Source Code: passwordbreach.py

import requests
import hashlib
import sys

def request_api_data(qchar):
  url = 'https://api.pwnedpasswords.com/range/' + qchar
  res = requests.get(url)
  if res.status_code != 200:
    raise RuntimeError(f' Error fetching : {res.status_code},check the api and try again')
  return res

def get_password_leaks_count(hashes,h_to_check):
  hashes= (line.split(':')for line in hashes.text.splitlines())
  for h,count in hashes:
    if h == h_to_check:
      return count
  return 0

def hashing(password):
  sha1password = hashlib.sha1(password.encode('utf=8')).hexdigest().upper()
  f5char,l5char = sha1password[:5], sha1password[5:]
  response= request_api_data(f5char)
  return get_password_leaks_count(response,l5char)

def main(args):
  for password in args:
    count=hashing(password)
    if count:
      print(f'{password} was found {count} times... its high on time to change the password {password} to better secured !')
    else:
       print(f'{password} was NOT found. It seems Good to Go!')
  return 'done!'

if __name__=='__main__':
    sys.exit(main(sys.argv[1:]))